// pages/paySuccessful/paySuccessful.js
const app = getApp()
var api = require('../../../utils/api.js')
var util = require('../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    items: {},
    numbers: '',
    total_fees: '',
    account_info:{
      companyName: app.globalData.companyName,
      taxNumber: app.globalData.taxNumber,
      bankName: app.globalData.bankName,
      bankNumber: app.globalData.bankNumber
    },
    notHint:false,
    showBounced:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.setData({
        oid: options.oid
      })
    var groupOrderKnowed = wx.getStorageSync('groupOrderKnowed');
    if (groupOrderKnowed) {
      this.setData({
        showBounced: false
      })
    } else {
      this.setData({
        showBounced: true
      })
    }
  },

  onShow:function(){
    this.orderDetails()
  },

//订单详情
  orderDetails: function () {
    var that = this;
    var oid = this.data.oid;
    api.POST({
      params: { "oid": oid },
      url: app.globalData.base_url + 'couponsorder/info',
      success: function (res) {
        if (util.isEmpty(res.data.code)) {
          var productList = res.data.data.productList;
          var productDetails = res.data.data;
          var invoice = productList.every(function (item) {
            return item.return_status == 0
          })

          that.setData({
            productList: productList,
            productDetails: productDetails
          })
        }
      },
      fail: function (fail) {
        util.showError("网络错误，请检查网络");
      }
    })
  },

  // 完成
  complete: function () {
    wx.redirectTo({
      url: '/center/pages/orderDetails/orderDetails?oid=' + this.data.oid+"&linktype=index"
    })
  },

  //不再提示
  notHint:function(){
    this.setData({
      notHint: !this.data.notHint
    })
  },

  //知道了
  know:function(){
    this.setData({
      showBounced:false
    })
    if (this.data.notHint){
      wx.setStorageSync('groupOrderKnowed', true);
    }
  },
   goLink: function () {
      wx.switchTab({
         url: '/pages/index/index'
      });
   },
})